//引入字体图标
require('../assets/fonts/iconfont.css')
//渲染tabbar函数
function renderTabbar(pathname) {
  //获取当前地址

  let arr = [
    {
      path: './home.html',
      title: '首页',
      icon: 'icon-home',
    },
    {
      path: './run.html',
      title: '运动',
      icon: 'icon-sports',
    },
    {
      path: './circle.html',
      title: '圈子',
      icon: 'icon-tiao',
    },
    {
      path: './mine.html',
      title: '我的',
      icon: 'icon-main',
    },
  ]
  let html = `
        ${arr
          .map((v, i) => {
            return `<a href="${v.path}" class="item df fdc aic ${
              v.path === `./${pathname}.html` && 'active'
            }">
            <i class="iconfont ${v.icon}"></i>
            <span>${v.title}</span>
        </a>`
          })
          .join('')}
    `
  //创建一个div
  let div = document.createElement('div')
  //设置div的class
  div.className = 'foot fn df jcsb aic'
  //给div里面填充内容
  div.innerHTML = html
  //body把div添加进最后
  document.body.appendChild(div)
}

//导出tabbar渲染函数
module.exports = renderTabbar
